package com.sunpy.niohttp.model;

import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * POST / HTTP/1.1
 * username: zhangsan
 * cache-control: no-cache
 * Postman-Token: 63dde61d-efbf-4aa7-9b7a-732f1c608603
 * Content-Type: text/plain
 * User-Agent: PostmanRuntime/7.1.1
 * Accept: **
 * Host:127.0.0.1:9999
 * accept-encoding:gzip,deflate
 * content-length:34
 * Connection:keep-alive
 *
 *{"level":5,"age":23,"name":"lisi"}
 */

/**
 * http协议请求对象模型
 */
public class SunpyRequest implements Serializable {

    /**
     * 请求方法
     */
    @NotEmpty
    private String method;

    /**
     * 请求url
     */
    @NotEmpty
    private String uri;

    /**
     * http协议的版本
     */
    private String version;

    /**
     * 请求头
     */
    private Map<String, String> headers = new HashMap<String, String>();

    /**
     * 请求体
     */
    private String body;

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getUri() {
        return uri;
    }

    public void setUri(String uri) {
        this.uri = uri;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    public void setHeaders(Map<String, String> headers) {
        this.headers = headers;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    @Override
    public String toString() {
        return "SunpyRequest{" +
                "method='" + method + '\'' +
                ", uri='" + uri + '\'' +
                ", version='" + version + '\'' +
                ", headers=" + headers +
                ", body='" + body + '\'' +
                '}';
    }
}
